const { defineConfig } = require('@vue/cli-service')
//按需引入elementui
const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')


module.exports = defineConfig({
  transpileDependencies: true,
  pages:{
    index:{
      //入口
      entry: 'src/main.js'
    }
  },
  //关闭语法检查
  lintOnSave:false,
  //开启代理服务器（方式一）
  //缺点：不能配置多代理以及无法控制请求是否需要走代理
  // devServer: {
  //   proxy: 'http://localhost:5002'
  // }

  //开启代理服务器（方式二）
  devServer: {
    proxy: {
      '/stu': {
        target: 'http://localhost:5002',
        pathRewrite:{'^/stu':''},
        ws: true,
        changeOrigin: true//用于控制请求头中的host值
      },
      '/car': {
        target: 'http://localhost:5001',
        pathRewrite:{'^/car':''},
        changeOrigin: true
      },
      '/api':{
        target: 'http://localhost:8888',
        pathRewrite:{'^/api':''},
        changeOrigin: true
      }
    }
  },
  //按需引入elementui
  configureWebpack: {
    plugins: [
      AutoImport({
        resolvers: [ElementPlusResolver()],
      }),
      Components({
        resolvers: [ElementPlusResolver()],
      }),
    ],
  }

})
